package com.example.demo.service.impl;

import com.example.demo.Mapper.RolePermissionMapper;
import com.example.demo.model.RolePermission;
import com.example.demo.model.RolePermissionExample;
import com.example.demo.service.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RolePermissionServiceImpl implements RolePermissionService {

    @Autowired
    private RolePermissionMapper rolePermissionMapper;

    @Override
    public List<RolePermission> selectByCondition(String role,String thePermission) {
        RolePermissionExample rolePermissionExample=new RolePermissionExample();
        RolePermissionExample.Criteria criteria=rolePermissionExample.createCriteria();

        if(role!=null)
            criteria.andRoleEqualTo(role);
        if(thePermission!=null)
            criteria.andThePermissionEqualTo(thePermission);

        return rolePermissionMapper.selectByExample(rolePermissionExample);
    }

}
